//
//  TextViewTableViewCell.m
//  Rail
//
//  Created by hychen on 2018/4/23.
//  Copyright © 2018年 Hychen. All rights reserved.
//

#import "TextViewTableViewCell.h"

@interface TextViewTableViewCell () <YCTextViewDelegate>

@end

@implementation TextViewTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self prepareTitleLabel];
        [self prepareTextView];
    }
    return self;
}

- (void)prepareTitleLabel {
    self.titleLabel = [UILabel labelWithText:@"" textColor:kBlackColor font:[UIFont systemFontOfSize:18]];
    [self.contentView addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.height.mas_equalTo(22);
    }];
}

- (void)prepareTextView{
    self.textView = [[YCTextView alloc] init];
    self.textView.font = [UIFont systemFontOfSize:14.f];
    self.textView.limitTextLength = 80;
    self.textView.limitStyle = LimitStyleExistAndAll;
    self.textView.placeholder = @"请输入内容";
    [self.textView setLimitTextLengthBlock:^{
        
    }];
    
    [self.contentView addSubview:self.textView];
    
    self.textView.layer.cornerRadius = 5.f;
    self.textView.layer.masksToBounds = YES;
    self.textView.layer.borderColor = [UIColor lightGrayColor].CGColor;
    self.textView.layer.borderWidth = 0.5f;
    
    [self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLabel.mas_bottom).offset(15);
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.height.mas_equalTo(120);
    }];
    
}

@end
